#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/4/12 15:38
# @Author : 闫峰
# @File    : globle_product_syc_check.py
from third_services.shopee.global_item.global_item import InterfaceGlobal
from utils.logging_tool.log_control import INFO

globle = InterfaceGlobal()


def golble_product_syc_check(ordersourceid):
    res = globle.get_global_item_list(ordersourceid)
    INFO.logger.info(f"渠道id: {ordersourceid} 下有{res['response']['total_count']}个item ")
    for item in res['response']['global_item_list']:
        res2 = globle.get_global_model_list(ordersourceid, item['global_item_id'])
        print(1)
        if res2.get('response').get('global_model'):
            for global_model in res2.get('response').get('global_model'):
                if global_model.get('global_model_sku') == "FX151933D2TZ4W60":
                    print(1)
        #     print(res2.get('response').get('global_model'))
        else:
            # 单体
            res2 = globle.get_global_item_info(ordersourceid, item['global_item_id'])
            print(1)
    offset = res['response']['offset']
    while True:

        res1 = globle.get_global_item_list(ordersourceid, offset)
        # print(res1)
        for item in res1['response']['global_item_list']:
            res2 = globle.get_global_model_list(ordersourceid, item['global_item_id'])
            if res2.get('response').get('global_model'):
                # 变体
                print(res2.get('response').get('global_model'))
            else:
                # 单体
                print(item)
        if res1['response']['has_next_page']:
            offset = res1['response']['offset']
        else:
            break


if __name__ == '__main__':
    golble_product_syc_check(13992)
